import java.io.File

// 调试扫描器功能
fun main() {
    println("=== 调试扫描器功能 ===")
    
    // 测试Download目录
    val downloadDir = File("/storage/emulated/0/Download")
    println("Download目录: ${downloadDir.absolutePath}")
    println("存在: ${downloadDir.exists()}")
    println("可读: ${downloadDir.canRead()}")
    
    if (downloadDir.exists()) {
        val files = downloadDir.listFiles()
        println("文件数量: ${files?.size ?: 0}")
        files?.forEach { file ->
            if (file.isFile) {
                val extension = file.name.substringAfterLast('.', "").lowercase()
                val supportedExtensions = setOf("epub", "pdf", "mobi", "doc", "docx", "txt")
                val isSupported = extension in supportedExtensions
                println("文件: ${file.name}, 扩展名: $extension, 大小: ${file.length()}, 支持: $isSupported")
            }
        }
    }
    
    // 测试test_file目录
    println("\n=== 测试test_file目录 ===")
    val testDir = File("D:/workspace/drl/system/EsayRead/test_file")
    println("测试目录: ${testDir.absolutePath}")
    println("存在: ${testDir.exists()}")
    println("可读: ${testDir.canRead()}")
    
    if (testDir.exists()) {
        val files = testDir.listFiles()
        println("文件数量: ${files?.size ?: 0}")
        files?.forEach { file ->
            if (file.isFile) {
                val extension = file.name.substringAfterLast('.', "").lowercase()
                val supportedExtensions = setOf("epub", "pdf", "mobi", "doc", "docx", "txt")
                val isSupported = extension in supportedExtensions
                println("文件: ${file.name}, 扩展名: $extension, 大小: ${file.length()}, 支持: $isSupported")
            }
        }
    }
    
    // 测试外部存储目录
    println("\n=== 测试外部存储目录 ===")
    val externalDir = File("/storage/emulated/0")
    println("外部存储: ${externalDir.absolutePath}")
    println("存在: ${externalDir.exists()}")
    println("可读: ${externalDir.canRead()}")
}